<?php

/**
 * Created by PhpStorm.
 * User: zhangligang
 * Date: 17/4/22
 * Time: 下午2:04
 */
namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 用户
 * Class User
 * @package App\Http\Models
 */
class User extends Model
{
    /**
     * table name
     * @var string
     */
    protected $table = 'app_user';

    protected $fillable = ['*'];

    /**
     * 关联买家地址
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function buyerAddress()
    {
        return $this->hasMany('App\Http\Models\BuyerAddress', 'buyer_id', 'id');
    }

    /**
     * 关联店铺
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function store()
    {
        return $this->hasOne('App\Http\Models\Store', 'seller_id', 'id');
    }

    /**
     * 用户属性
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function attribute()
    {
        return $this->hasMany('App\Http\Models\UserAttribute', 'user_id', 'id');
    }

    public function role()
    {
        return $this->belongsTo('App\Http\Models\Role', 'role_id');
    }

}